﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Data;
using System.Text;
using System.Threading.Tasks;
using Aden.DAL.StockData;
using Aden.Util.Common;

namespace Aden.DAL.StockData
{
    public class POReturn : Stockout
    {
        private Purchase.PurchaseOrderFactory pofactory = new Purchase.PurchaseOrderFactory();
        public POReturn(string appGuid, string costCenterCode, string orderDate, string createUser)
            : base(appGuid, costCenterCode, "POReturn", orderDate, createUser) { }


        public override Dictionary<string, object> ShowComponents()
        {
            Dictionary<string, object> dic = new Dictionary<string, object>();

            dic["Item"] = new Dictionary<string, object>() { { "change", false } };
            dic["ItemDesc"] = new Dictionary<string, object>() { { "visible", false } };
            dic["Price"] = new Dictionary<string, object>() { { "visible", true }, { "change", false } };
            dic["QrderQty"] = new Dictionary<string, object>() { { "visible", false } };
            dic["StockQty"] = new Dictionary<string, object>() { { "visible", false } };
            dic["ToCostCenter"] = new Dictionary<string, object>() { { "visible", false } };
            dic["BusinessType"] = new Dictionary<string, object>() { { "visible", false }, { "change", false } };
            dic["InQty"] = new Dictionary<string, object>() { { "visible", true } };
            dic["Remark"] = new Dictionary<string, object>() { { "visible", true }, { "change", true } };
            return dic;
        }

        public override List<Dictionary<string, object>> GetDates()
        {
            DateTime? date1 = stocktrans.GetMinPriceListDate(CostCenterCode);
            // PO getdate
            List<Dictionary<string, object>> dic = pofactory.ClosePODates(CostCenterCode).ToList();
            if (date1 == null)
                return dic;

            DateTime d1 = date1 == null ? DateTime.Parse("2000-01-01") : (DateTime)date1;
           
            return dic.Where(q => DateTime.Parse(q["date"].ToStringTrim()) > d1).ToList();
        }
    }
}
